#导出数据
clickhouse-client --query="SHOW CREATE DATABASE sz_yc" > schema.sql

sed 's/\\n/ /g; s/\\'\''/'\''/g' schema.sql | awk '{print $0 ";"}' > schema_clean.sql      #注意删除里面的视图

clickhouse-client --query="SHOW TABLES FROM sz_yc" | while read table; do clickhouse-client --query="SHOW CREATE TABLE sz_yc.$table" >> schema.sql; done
clickhouse-client --query="SHOW TABLES FROM sz_yc" | while read table; do clickhouse-client --query="SELECT * FROM sz_yc.$table FORMAT Native" > $table.native; done

clickhouse-client --multiquery --ignore-error < schema_clean.sql
for file in *.native; do table=${file%.native}; clickhouse-client --query="INSERT INTO sz_yc.$table FORMAT Native" < $file; done